Function Parameters


Function Parameters

To avoid writing similar code in a program, a function can take one or more parameters so that the function can be used in different situations. The figure below shows how to write a function that takes one parameter. In this case, the parameter indicates how many asterisks will be used to build the line.
Para evitar escribir código similar en un programa, una función puede tomar uno o más parámetros de tal forma que la función pueda ser usada en distintas situaciones. En la figura de abajo se muestra como escribir una función que toma un parámetro. En este caso, el parámetro indica cuantos asteriscos se usarán para construir la línea.

FunctionStructure

Tip
The code below shows how to call a function that takes parameters. In this specific case, the function takes one integer value. The function is called three times. The first time that the function is called, the parameter value is 3. Thus, the number of asterisk is 3, and the line is draw using three asterisks. Observe how a function can behave differently depending on its input parameters.
El código de abajo muestra cómo llamar una función que toma parámetros. En este caso específico, la función toma un valor entero. La función es llamada tres veces. La primera vez que la función es llamada, el valor del parámetro es tres. Así, el número de asteriscos es 3, y la línea es dibujada usando tres asteriscos. Observe como una función se puede comportar en forma diferente dependiendo en sus parámetros de entrada.

FunctionParameter

© Copyright 2000-2021 Wintempla selo. All Rights Reserved. Jul 22 2021. Home